{extend name="admin/base" /}
{block name="resources"}
<style>
.img-box{width:60px;height:60px;border:1px dashed #4685fd;position: relative;display: flex;    overflow: hidden;}
.img-info{
	width: 100%;
	height: 100%;
	margin: 0 auto;
	line-height: 100%;
	vertical-align: middle;
}
.default-img-logo{display:inline-block;width:25px}
dl.input-item-inline {
	width: 32%;
	clear: unset;
	display: inline-block;
	box-sizing: border-box;
}
dl.input-item-inline dd{
	width: 48%;
}
.item-line {
	width: 36%!important;
}
.hint {
	color: rgba(0,0,0,.3);
	margin-top: 20px;
}
</style>

{/block}
{block name="main"}
<div class="set-style">
	<h4><span></span>网站基础设置</h4>
	<dl>
		<dt>网站名称：</dt>
		<dd>
			<input id="title" type="text" value="{$website.title}" class="input-common" />
		</dd>
	</dl>
	<dl>
		<dt>官方网址：</dt>
		<dd>
			<input id="web_url" type="text" value="{$website.web_url}" class="input-common" />
		</dd>
	</dl>
	<dl>
		<dt>网站logo：</dt>
		<dd class="item-line">
			<div class="img-box" style="width: 100px">
				<label style="margin:auto">
				{if condition="$website.logo"}
					<img class="img-info" id="preview_logo" src="{:__IMG($website.logo)}" data-src="{:__IMG($website.logo)}" title="修改">						
				{else/}
					<div class="default-img-logo default_logo">												
						<img src="__STATIC__/blue/img/default.png">						
					</div>
					<img class="img-info" id="preview_logo" src="" data-src="" style="display:none" title="修改">											
				{/if}
					<input class="input-file" name="file_upload" id="uploadImg" type="file" onchange="imgUpload(this, 'logo');" title="上传" style="display:none">
				</label>
				<input type="hidden" id="logo" value="{if condition='$website.logo'}{$website.logo}{/if}" />											
			</div>
			<p class="hint">
				<span>网站的长方形logo.  建议使用<i class="important-note">宽280</i>像素-<i class="important-note">高50</i>像素内的<i class="important-note">GIF</i>或<i class="important-note">PNG</i>透明图片</span>
			</p>
		</dd>
		<dd class="item-line">
			<div class="img-box">
				<label style="margin:auto">
					{if condition = "$website.web_wechat_share_logo"}
					<img class="img-info" id="preview_wechat_share_logo" src="{:__IMG($website.web_wechat_share_logo)}" data-src="{:__IMG($website.web_wechat_share_logo)}" title="修改">
					{else/}
					<div class="default_wechat_share_logo default-img-logo">
						<img src="__STATIC__/blue/img/default.png">
					</div>
					<img class="img-info" id="preview_wechat_share_logo" src="" data-src="" style="display:none" title="修改">
					{/if}
					<input class="input-file" name="file_upload" id="uploadImgwechat_share_logo" type="file" onchange="imgUpload(this, 'wechat_share_logo');" title="上传" style="display:none">
				</label>
				<input type="hidden" id="wechat_share_logo" value="{if condition='$website.web_wechat_share_logo'}{$website.web_wechat_share_logo}{/if}" />
			</div>
			<p class="hint">
				<span>网站的正方形logo. 建议使用<i class="important-note">宽80</i>像素-<i class="important-note">高80</i>像素内的正方形图片</span>
			</p>
		</dd>
	</dl>
<!--	<dl>-->
<!--		<dt>网站logo (正方形)：</dt>-->
<!--		<dd>-->
<!--			<div class="img-box">-->
<!--				<label style="margin:auto">-->
<!--					{if condition = "$website.web_wechat_share_logo"}-->
<!--						<img class="img-info" id="preview_wechat_share_logo" src="{:__IMG($website.web_wechat_share_logo)}" data-src="{:__IMG($website.web_wechat_share_logo)}" title="修改">	-->
<!--					{else/}-->
<!--						<div class="default_wechat_share_logo default-img-logo">												-->
<!--							<img src="__STATIC__/blue/img/default.png">						-->
<!--						</div>-->
<!--						<img class="img-info" id="preview_wechat_share_logo" src="" data-src="" style="display:none" title="修改">						-->
<!--					{/if}-->
<!--					<input class="input-file" name="file_upload" id="uploadImgwechat_share_logo" type="file" onchange="imgUpload(this, 'wechat_share_logo');" title="上传" style="display:none">					-->
<!--				</label>-->
<!--				<input type="hidden" id="wechat_share_logo" value="{if condition='$website.web_wechat_share_logo'}{$website.web_wechat_share_logo}{/if}" />											-->
<!--			</div>			-->
<!--			<p class="hint">-->
<!--				<span>网站的正方形logo. 建议使用<i class="important-note">宽80</i>像素-<i class="important-note">高80</i>像素内的正方形图片</span>-->
<!--			</p>-->
<!--		</dd>-->
<!--	</dl>-->
	
	<dl>
		<dt>网站公众号二维码：</dt>
		<dd>
			<div class="img-box">
				<label style="margin:auto">
					{if condition="$website.web_qrcode"}
						<img class="img-info" id="preview_web_qrcode" src="{:__IMG($website.web_qrcode)}" data-src="{:__IMG($website.web_qrcode)}" title="修改">	
					{else/}
						<div class="default_web_qrcode default-img-logo">												
							<img src="__STATIC__/blue/img/default.png">						
						</div>
						<img class="img-info" id="preview_web_qrcode" src="" data-src="" style="display:none" title="修改">						
					{/if}
					<input class="input-file" name="file_upload" id="uploadImgweb_qrcode" type="file" onchange="imgUpload(this, 'web_qrcode');" title="上传" style="display:none">
				</label>	
				<input type="hidden" id="web_qrcode" value="{if condition='$website.web_qrcode'}{$website.web_qrcode}{/if}" />										
			</div>	
			<p class="hint">
				<span>网站绑定的微信公众号的二维码.建议使用<i class="important-note">宽100</i>像素-<i class="important-note">高100</i>像素内的<i class="important-note">GIF</i>或<i class="important-note">PNG</i>透明图片</span>
			</p>
			
		</dd>
	</dl>
	<h4><span></span>网站联系设置</h4>
	<dl class="input-item-inline">
		<dt>电话/手机：</dt>
		<dd>
			<p>
				<input id="web_phone" type="text" value="{$website.web_phone}" class="input-common" />
			</p>
		</dd>
	</dl>
	<dl class="input-item-inline">
		<dt>邮箱：</dt>
		<dd>
			<p>
				<input id="web_email" type="text" value="{$website.web_email}" class="input-common" />
			</p>
		</dd>
	</dl>
	
	<dl class="input-item-inline">
		<dt>QQ号：</dt>
		<dd>
			<p>
				<input id="web_qq" type="text" value="{$website.web_qq}" class="input-common" />
			</p>
		</dd>
	</dl>
	<dl  class="input-item-inline">
		<dt>微信号：</dt>
		<dd>
			<p>
				<input id="web_weixin" type="text" value="{$website.web_weixin}" class="input-common" />
			</p>
		</dd>
	</dl>
	<dl class="input-item-inline">
		<dt>联系地址：</dt>
		<dd>
			<input id="web_address" type="text" value="{$website.web_address}" class="input-common long" />
		</dd>
	</dl>
	<h4><span></span>备案与统计设置</h4>
<!-- 	<dl>
		<dt>网站ICP备案号：</dt>
		<dd>
			<p>
				<input id="web_icp" type="text" value="{$website.web_icp}" class="input-common" />
			</p>
		</dd>
	</dl>
	<dl>
		<dt>网站公安备案：</dt>
		<dd>
			<p>
				<input id="web_gov_record" type="text" value="{$website.web_gov_record}" class="input-common" maxlength="30"/>
			</p>
		</dd>
	</dl>
	<dl>
		<dt>网站公安备案链接：</dt>
		<dd>
			<p>
				<input id="web_gov_record_url" type="text" value="{$website.web_gov_record_url}" class="input-common" maxlength="200"/>
			</p>
		</dd>
	</dl> -->
	<dl>
		<dt>商城第三方统计代码：</dt>
		<dd>
			<textarea name="store_zy" rows="2" id="third_count" class="textarea-common">{$website.third_count}</textarea>
			<p class="hint">第三方统计的脚本代码</p>
		</dd>
	</dl>
	
	<dl>
		<dt></dt>
		<dd><button class="btn-common btn-big" onclick="setConfigAjax();">保存</button></dd>
	</dl>
</div>
<script src="__STATIC__/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="__STATIC__/js/file_upload.js" type="text/javascript"></script>
<script>
//图片上传
function imgUpload(event, id) {
	var fileid = $(event).attr("id");
	var data = { 'file_path' : "config" };
	uploadFile({
		url: __URL(ADMINMAIN + '/config/uploadimage'),
		fileId: fileid,
		data : data,
		callBack: function (res) {
			if(res.code){
				$("#" + id).val(res.data.path);
				$("#text_" + id).val(res.data.path);		
				$("#preview_"+ id).attr("data-src",__IMG(res.data.path));
				$("#preview_"+ id).attr("src", __IMG(res.data.path));
				$("#preview_"+ id).show();
				$("#preview_"+ id).parent().parent().css("border","0px");
				$(".default_"+ id).hide();
				showTip(res.message,"success");
			}else{
				showTip(res.message,"error");
			}
		}
	});
}

function setConfigAjax() {
	var title = $("#title").val();
	var web_url = $("#web_url").val();
	var web_popup_title = $("#web_popup_title").val();
	var Logo = $("#logo").val();
	var web_wechat_share_logo = $("#wechat_share_logo").val();//网站微信分享logo
	var web_qrcode = $("#web_qrcode").val();
	var web_phone = $("#web_phone").val();
	var web_email = $("#web_email").val();
	var web_qq = $("#web_qq").val();
	var web_weixin = $("#web_weixin").val();
	var web_address = $("#web_address").val();
	// var web_icp = $("#web_icp").val();
	var third_count = $("#third_count").val();
	// var web_gov_record = $("#web_gov_record").val();
	// var web_gov_record_url = $("#web_gov_record_url").val();
	$.ajax({
		type : "post",
		url : "{:__URL('ADMIN_MAIN/config/webconfig')}",
		data : {
			'title' : title,
			'web_url' : web_url,
			'web_address' : web_address,
			'logo' : Logo,
			'web_qrcode' : web_qrcode,
			'web_phone' : web_phone,
			'web_email' : web_email,
			'web_qq' : web_qq,
			'web_weixin' : web_weixin,
			// 'web_icp' : web_icp,
// 			'web_style_pc' : web_style_pc,
			'third_count' : third_count,
			'web_popup_title' : web_popup_title,
			'web_wechat_share_logo' : web_wechat_share_logo
			// 'web_gov_record' : web_gov_record,
			// 'web_gov_record_url' : web_gov_record_url
		},
		success : function(data) {
			if (data["code"] > 0) {
				showTip(data["message"],"success");
				setTimeout(function(){window.location.href = "{:__URL('ADMIN_MAIN/config/webconfig')}"},2000);
			} else {
				showTip(res.message,"error");
			}
		}
	});
}
</script>
{/block}